﻿using EmbeddedSharp.Core;
using EmbeddedSharp.Core.Function;

namespace EmbeddedSharp.Scripting.Function.Context {
    public class ExitNode : FuncNode {

        public ExitNode()
            : base() {
            base.Value = "exit";
        }

        public override object Evaluate() {
            if (Parameters.Count < 1) {
                throw new TerminateException();
            }

            string msg = Parameters[0].Evaluate().ToString();
            throw new TerminateException(msg);
        }
    }
}
